/**
 * 预约
 */
class Appointment extends egret.DisplayObjectContainer {

    private moreBtn: egret.Bitmap = Main.createBitmapByName("appointment_open_png");

    public constructor() {
        super();
        this.once(egret.Event.ADDED_TO_STAGE, this.init, this);
    }

    private init() {
        this.addChild(this.moreBtn);
        this.moreBtn.x = this.stage.stageWidth * .8;
        this.moreBtn.y = this.stage.stageHeight * .1;
        this.moreBtn.touchEnabled = true;
        this.moreBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.moreBtnTap, this);
    }

    private moreBtnTap() {
        /**弹窗容器 */
        const container = new egret.Sprite();
        this.stage.addChild(container);
        container.graphics.beginFill(0, .5);
        container.graphics.drawRect(0, 0, this.stage.stageWidth, this.stage.stageHeight);
        container.graphics.endFill();
        container.touchEnabled = true;
        container.addEventListener(egret.TouchEvent.TOUCH_BEGIN, Main.superStopPropagation, this);
        /** 弹窗背景图 */
        const alertImg = Main.createBitmapByName(`appointment_alert_png`);
        const oH = alertImg.width / alertImg.height;
        container.addChild(alertImg);
        alertImg.width = this.stage.stageWidth * .7;
        alertImg.height = alertImg.width / oH;
        Main.anchorCenter(alertImg);
        alertImg.x = this.stage.stageWidth * .5;
        alertImg.y = this.stage.stageHeight * .5 + 30;
        /** 弹窗关闭按钮 */
        const closeBtn: egret.Bitmap = Main.createBitmapByName("appointment_close_png");
        container.addChild(closeBtn);
        closeBtn.x = this.stage.stageWidth * .8;
        closeBtn.y = this.stage.stageHeight * .1;
        closeBtn.touchEnabled = true;
        closeBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
            this.stage.removeChild(container);
        }, this);

    }

}